package org.kfive.nova.test.string;

import java.lang.reflect.Field;

/**
 * Created by admin on 2017-04-13.
 */
public class ModifyString {
    public static void main(String[] args) {
        String data ="abcd";
        try {
            System.out.println("修改前"+data);
            Field field = String.class.getDeclaredField("value");
            field.setAccessible(true);
            char[] value = (char[])field.get(data);
            value[3]='e';
            System.out.println("修改后"+data);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
